package cn.jiyun.controller;

import cn.jiyun.service.OrderInfoService;
import com.jiyun.Result.Result;
import com.jiyun.common.pojo.product.OrderInfo;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("carProduct/OrderInfo")
@Slf4j
public class OrderInfoController {

    @Resource
    private OrderInfoService orderInfoService;

    @GetMapping("findOrderInfoList/{token}")
    public Result findOrderInfoList( @PathVariable String token){
        return orderInfoService.findOrderInfoList(token);
    }

    @GetMapping("StatusModification/{id}")
    public Result StatusModification(@PathVariable Integer id){
    	return orderInfoService.StatusModification(id);
    }

    @GetMapping("cancelOrder/{id}")
    public Result cancelOrder(@PathVariable Integer id){
    	return orderInfoService.cancelOrder(id);
    }

    @PostMapping("add")
    public Result findOrderInfoById(OrderInfo orderInfo){
    	return orderInfoService.add(orderInfo);
    }

    @GetMapping("findByOrderNumber/{trade}")
    public OrderInfo findByOrderNumber(@PathVariable String trade){
    	return orderInfoService.findByOrderNumber(trade);
    }

    @GetMapping("update/{id}")
    public void update(@PathVariable Integer id){
        log.info("id:{}", id);
    	orderInfoService.update(id);
    }
}
